//
// Created by DengLibin on 2018/12/11 0011.
//
/**
 * 对象参数
 */
#include <iostream>
using namespace std;
class Dog
{
private:
    string  name;
public:
     Dog(string & name)
    {
        this->name = name;
    }
    Dog(const Dog &dog)
    {
         this->name = dog.name;
         cout << "拷贝构造函数" << endl;
    }
    void show() const
    {
         cout << "name = " << this->name << endl;
    }
};
//对象作为函数参数,那么传入的是对象的一份拷贝(会执行一次拷贝构造函数)
void test1(Dog dog)
{
    dog.show();
}
//对象的引用作为函数参数(防止函数内存修改对象的属性,加const)
void test2(const Dog & dog)
{
    dog.show();
}
int main8()
{
    string name = "旺财";
    Dog dog(name);
   // test1(dog);
    test2(dog);
    return 0;
}
